"""
@File    :   router.py
@Time    :   2024/04/21 22:14:09
@Author  :   Qrj
@Email   :   923207736@qq.com
@description   :   字典类型相关路由
"""
from typing import Annotated

from fastapi import APIRouter, Depends

from src.business.admin.system.oauth2.token.dependencies.no_introduction import (
    DependVerifyAccessTokenMenumPermission,
)
from src.enums.permission_operation import PermissionOperationEnum
from src.utils.unified_response import SuccessApiJSONResponse

from .dependencies.route_depend import (
    route_depend_create_dict_type,
    route_depend_delete_dict_type,
    route_depend_get_dict_type,
    route_depend_list_dict_type,
    route_depend_update_dict_type,
    route_depend_update_dict_type_status,
)
from .schemas.out import DictTypeCompleteOutSchema

# 构建权限验证相关的依赖项
# 查
depend_select_permission_verify = DependVerifyAccessTokenMenumPermission(
    __file__, PermissionOperationEnum.select.value
)
# 增
depend_create_permission_verify = DependVerifyAccessTokenMenumPermission(
    __file__, PermissionOperationEnum.create.value
)
# 改
depend_update_permission_verify = DependVerifyAccessTokenMenumPermission(
    __file__, PermissionOperationEnum.update.value
)
# 删
depend_delete_permission_verify = DependVerifyAccessTokenMenumPermission(
    __file__, PermissionOperationEnum.delete.value
)


# 创建路由
router = APIRouter(
    prefix="/admin/system/dict/type",
    tags=[
        "后台字典类型接口",
    ],
)


@router.get("/get", summary="查询单个字典类型")
async def route_get_dict_type(
    verify_menu_permission: Annotated[None, Depends(depend_select_permission_verify)],
    dict_type: Annotated[
        DictTypeCompleteOutSchema, Depends(route_depend_get_dict_type)
    ],
):
    return SuccessApiJSONResponse(data=dict_type)


@router.post("/list", summary="查询字典类型完整信息列表")
async def route_list_tenant_package(
    verify_menu_permission: Annotated[None, Depends(depend_select_permission_verify)],
    list_result: Annotated[
        tuple[list[DictTypeCompleteOutSchema], int],
        Depends(route_depend_list_dict_type),
    ],
):
    search_pagination_result, search_total = list_result
    data = {"result": search_pagination_result, "total": search_total}
    return SuccessApiJSONResponse(data=data)


@router.post("/create", summary="创建字典类型")
async def route_create_dict_type(
    verify_menu_permission: Annotated[None, Depends(depend_create_permission_verify)],
    created_id: Annotated[int, Depends(route_depend_create_dict_type)],
):
    data = {"created_id": created_id}
    return SuccessApiJSONResponse(data=data)


@router.post("/update", summary="修改字典类型")
async def route_update_dict_type(
    verify_menu_permission: Annotated[None, Depends(depend_update_permission_verify)],
    update_operation: Annotated[None, Depends(route_depend_update_dict_type)],
):
    return SuccessApiJSONResponse()


@router.post("/update-status", summary="修改字典类型状态")
async def route_update_menu_status(
    verify_menu_permission: Annotated[None, Depends(depend_update_permission_verify)],
    update_status_operation: Annotated[
        None, Depends(route_depend_update_dict_type_status)
    ],
):
    return SuccessApiJSONResponse()


@router.post("/delete", summary="删除字典类型")
async def route_delete_dict_type(
    verify_menu_permission: Annotated[None, Depends(depend_delete_permission_verify)],
    delete_operation: Annotated[None, Depends(route_depend_delete_dict_type)],
):
    return SuccessApiJSONResponse()
